package com.love.mire;

import android.os.Bundle;
import android.support.v7.app.AppCompatActivity;
import android.support.v7.widget.Toolbar;
import android.widget.LinearLayout;
import android.widget.RelativeLayout;
import android.widget.Toast;

import java.util.ArrayList;
import java.util.List;

public class MainActivity extends AppCompatActivity implements HomeColumnar.OnInsideTouchListener {

    LinearLayout arc;
    RelativeLayout pillars, linear;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
        Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
        setSupportActionBar(toolbar);


        /*arc = (LinearLayout) findViewById(R.id.arc);//圆弧计分
        arc.addView(new HomeArc(this, 100));*/

        List<Score> list = new ArrayList<Score>();
        ;//柱状图  范围10-100
        for (int i = 1; i <= 12; i++) {
            Score s = new Score();
            s.date = i + "月";
            s.score = getRandom(10, 100);
            list.add(s);
        }
        pillars = (RelativeLayout) findViewById(R.id.pillars);
        HomeColumnar homeColumnar = new HomeColumnar(this, list);
        homeColumnar.setListener(this);
        pillars.addView(homeColumnar);

        /*List<Integer> lists = new ArrayList<Integer>();//线性图  范围10-100
        for (int i = 0; i < 48; i++) {
            if (i < 8 || i == 28 || i == 12 || i == 18 || i == 20 || i == 30
                    || i == 34) {
                lists.add(0);
            } else {
                lists.add(getRandom(0, 500));
            }
        }
        linear = (RelativeLayout) findViewById(R.id.linear);
        linear.addView(new HomeDiagram(this, lists));*/
    }

    public int getRandom(int min, int max) {
        return (int) Math.round(Math.random() * (max - min) + min);
    }

    @Override
    public void show(Score score) {
        Toast.makeText(MainActivity.this, score + "", Toast.LENGTH_SHORT).show();
    }
}
